package Book;

public class Book {
    private String title;
    private int pageNum;
    private String type;

    public Book(int pageNum, String type) {
        title="计算机";
        testPage();
        this.type = type;
    }

    public Book(String title, int pageNum, String type) {
        this.title = title;
        this.type = type;
        testPage();
    }

    private void testPage() {
        try {
            if (pageNum > 200) {
                this.pageNum = pageNum;
            } else {
                pageNum = 200;
                throw new Exception();
            }
        } catch (Exception e) {
            System.out.println("页数不能少于200页");
        }
    }

    public void detail(){
        System.out.println(title);
        System.out.println(pageNum);
    }
}
